\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
%\usepackage[english,eng-noquoting]{babel}
%\selectlanguage{English}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{array}
\usepackage{multirow}
\newcommand{\MYhref}[3][blue]{\href{#2}{\color{#1}{#3}}}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{subcaption}
\usepackage{color}
\usepackage[left=2.50cm, right=2.50cm, top=3.00cm, bottom=3.00cm]{geometry}
\usepackage{vmargin}
\usepackage{float}
\usepackage{secdot}
\usepackage{chngcntr}
\usepackage{multirow}
\usepackage[bottom]{footmisc}
\captionsetup[subfloat]{position=top}
\usepackage[justification=centering]{caption}
\setlength\parindent{24pt}
\usepackage{indentfirst}
\setmarginsrb{2.5cm}{1.5cm}{2.5cm}{1.5cm}{10pt}{1.2cm}{0pt}{1cm}
%\setmarginsrb{hleftmargini}{htopmargini}{hrightmargini}{hbottommargini}{hheadheighti}{hheadsepi}{hfootheighti}{hfootskipi}
\usepackage{natbib}
\usepackage{changepage}
\renewcommand{\baselinestretch}{1.15}
\setlength{\parskip}{0.3em}
\bibliographystyle{apalike}
\setcitestyle{authoryear,open={(},close={)}}
\usepackage{setspace}
\onehalfspacing


\begin{document}
\title{Learning about the Long Run: Replication Package}


\author{Leland E. Farmer, Emi Nakamura, J\'{o}n Steinsson}
%\date{\today}
\date{December 2023}
\maketitle
This document contains instructions on how to use the replication files in this replication package. The replication package has 4 folders. The four sections of this document discussed the material in each of these folders. First, we give a brief summary: 
\begin{itemize}
    \item \textbf{Data:} This folder contains code that replicates Figures 1, 2, 3 and 5, Tables 1 and 2, and Appendix Table A.1.
    \item \textbf{T-bill results:} This folder contains code that replicates Figures 4, 6, 7, 8 and 9, and Tables 3 and 4. It also contains code that replicates all the Appendix figures and tables related to the interest rate application in the paper.
    \item \textbf{GDP Results:} This folder contains code that replicates Figures 10, 11, and 12, and Table 5.
    \item \textbf{Monte Carlo:} This folder contains code that replicates all results in Section 6. 
\end{itemize}
We now give a more detailed description of how to use the code in these folders to replicate the results of the paper.
\section{Data}
Run the Matlab file `data\_regs.m' to produce the results in Tables 1 and 2. Run the Matlab file `data\_figs.m' to produce Figures 1, 2 and 3. The data required to run these files is in the `Data' folder. The Matlab file `figure\_5.m' produces Figure 5 and uses the data in the Excel file `UKConsoleRate.xlsx'. 

The code and data to replicate Appendix Table A.1 are in the subfolder `Individual\_regressions'. Run the Matlab file `Pooled\_Regressions.m' to replicate the pooled regressions. Run the Matlab code `Median\_Regressions.m' to replicate the median regressions.  

\section{T-bill results}
In this folder, the main code that runs the unobserved components model of the interest rate section is called `tblPriorEstimationSmooth.m'. The lines of code that are used to estimate the prior hyperparameters have been commented out. The code takes the optimal hyperparameters as given and performs the Bayesian analysis. The output of this code is a Matlab data file called `tblResults\_SlopeCoefficients\_Level\_SmoothL.mat'. This file will be fairly large (about 2 GB). The regression results of Tables 3 and 4 are reproduced by loading `tblResults\_SlopeCoefficients\_Level\_SmoothL.mat' into the Matlab code `tblRegressions.m' and running this code. Figures 4, 6, 7 and 8 are reproduced by loading `tblResults\_SlopeCoefficients\_ Level\_SmoothL.mat' in the Matlab code `tblFigs.m' and running it.

In order to estimate the prior hyperparameters, the lines in `tblPriorEstimationSmooth.m' that do this -- lines 11 through 19 -- need to be uncommented. 

To reproduce the results in Appendix E, first run the Matlab code `tblPriorEstimation \_Direct.m'. The output of this code is a Matlab data file called `tblResults\_Direct\_SmoothL.mat'. Then, run `tblRegressions.m' and `tblFigs.m', but first comment out the lines in these files that load `tblResults\_SlopeCoefficients\_Level\_SmoothL.mat' and uncomment the lines that load `tblResults\_Direct\_SmoothL.mat'. 

To reproduce the results in Appendix F.1, first run the matlab code `tblPriorEstimation\_Loose.m'. The output of this code is a matlab data file called `tblResults\_Loose\_SmoothL .mat'. Then, run `tblRegressions.m' and `tblFigs.m', but first comment out the lines in these files that load `tblResults\_SlopeCoefficients\_Level\_SmoothL.mat' and uncomment the lines that load `tblResults\_Loose\_SmoothL.mat'. 

To reproduce the results in Appendix F.2, first run the Matlab code `tblPriorEstimation\_LookAhead.m'. The output of this code is a Matlab data file called `tblResults\_LookAhead \_SmoothL.mat'. Then, run `tblRegressions.m' and `tblFigs.m', but first comment out the lines in these files that load `tblResults\_SlopeCoefficients\_Level\_SmoothL.mat' and uncomment the lines that load `tblResults\_LookAhead\_SmoothL.mat'. 

To reproduce Figure 9 and the results of Appendix G, first run the Matlab code `tblPriorEstimation\_Break.m'. The output of this code is a Matlab data file `tblResults\_SlopeCoefficients \_Level\_Break\_SmoothTL.mat'. Then, run the code `tblResultsBreak.m'. The first section of this code reproduces the figures in Appendix G and Figure 9 of the main paper. The second section of this code reproduces the regression results in Appendix Tables G.1 and G.2. The last section of this code is for Appendix Tables G.3 and G.4. The results for Table G.3 are contained in the variables `cpRestrictedGam', `seRestrictedGam', and `r2RestrictedGam' for the data, and `cpRestrictedGamModel', `seRestrictedGamModel', and `r2RestrictedGamModel' for the model. The results for Table G.4 are contained in the variables `cpRestrictedB', `seRestrictedB', and `r2RestrictedB' for the data, and `cpRestrictedBModel', `seRestrictedBModel', and `r2RestrictedBModel', for the model'. 

To produce the results in Appendix Table F.5, run the code `RMSE\_analysis.m'. 


\section{GDP results}
The code that runs the UC model of section 5 is 'gdpPriorEstimation.m'. The output of this code is a Matlab data file called 'gdpResults\_AllCoefficients\_Levels5.mat'. After obtaining the 'gdpResults\_AllCoefficients\_Levels5.mat' file, run the Matlab code 'gdpRegressions.m' to produce the regression results of the 'UC Model' rows in Table 5 (the regression results for the CBO rows in Table 5 are in the Data section of the replication package). Run the code in 'gdpFigs.m' to produce Figures 10, 11, and 12. 


\section{Monte Carlo}
To replicate the results in section 6 of the paper, run `ucSimulation2.m’. The first few lines of code in this file set the true parameters of the data-generating process and the prior hyperparameters that agents start off with. The code is initially set to match the `downward biased' initial priors case in the paper. To produce results for the unbiased and upward biased cases, adjust these first few lines of the code appropriately. 

The results of these Monte Carlo draws are stored in the Matlab Data file the name of which is chosen at the top of `ucSimulation2.m’. We include results for the three cases reported in the paper in the replication package. These are in files `simulationGibbs\_New\_DownwardBiasedPriors .mat’, `simulationGibbs\_New UnBiasedPriors.mat’ and `simulationGibbs\_New\_UpwardBiased-Priors.mat’. 

Load one of these files into `MonteCarlo Results.m’ and run this file to produce the results in Tables 6 and 7 for that case. This code also produces a figure with the evolution of $\rho$ and $\gamma$. Figure 14 in the paper is this figure when `simulationGibbs\_New\_DownwardBiasedPriors.mat’ is loaded into `MonteCarlo Results.m’. 

Run ’Figure\_13.m’ to produce Figure 13. 

The code to produce Figure 15 is in the `Figure\_15.m’ file. This code uses two Matlab data files: `simulationGibbs\_New\_DownwardBiasedPriors\_1950.mat’ and
`simulationGibbs\_New \_DownwardBiasedPriors\_1950\_WOG.mat’. These files are included in the replication package. The first of these two files is produced by running `ucSimulation2.m’ but by changing the estimation start date to 1. The second file is produced by running `ucSimulation2.m’ with the estimation start date equal to 1, the true value of $\gamma$ set equal to 0.01, and the mean and standard deviation of the $\gamma$ prior set to 0.01 as well.

\end{document}